package com.example.leanserver;

import android.app.Service;
import android.content.Intent;
import android.os.IBinder;
import android.os.RemoteException;

public class countService extends Service {
    public countService() {
    }

    private int count;
    private AIDLServerBinder serviceBinder = new AIDLServerBinder();

    class AIDLServerBinder extends IMyCount.Stub {
        @Override
        public int getcount() throws RemoteException {
            return count;
        }
    }

    @Override
    public IBinder onBind(Intent intent) {
        return serviceBinder;
    }

    @Override
    public void onCreate() {
        new Thread(new Runnable() {
            @Override
            public void run() {
                while (count < 100) {
                    try {
                        Thread.sleep(1000);
                        count++;
                    } catch (InterruptedException e) {
                    }
                }
            }

        }).start();

    }

    @Override
    public void onDestroy() {
        super.onDestroy();
    }


}
